

const store = require('./store/index.js');
const {changeNameAction,changeCountAction} = require('./store/actionCreate.js')


// 订阅 store
const unsubscribe = store.subscribe(()=>{
    console.log('订阅store 数据',store.getState());
})
// 取消订阅
// unsubscribe()

console.log(store.getState());

// 修改store
// // 1.创建一个action  描述发生什么的对象
// const nameAction ={type:'change_name',name:'jack'}
// // 2. store 执行 dispatch 方法  3. reducer 接收action ,
// store.dispatch(nameAction)

// store.dispatch({type:"change_name",name:'oscar'})
// console.log(store.getState());



store.dispatch(changeNameAction('leo'))
store.dispatch(changeNameAction('oscar'))
store.dispatch(changeCountAction(300))
store.dispatch(changeNameAction('jack'))

console.log(store.getState());